package com.example.demo;

import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/123")
public class Server {
    @RequestMapping (value = "/hellos",method = RequestMethod.GET )
    public String hello(){
        return "hello Spring Boot";
    }
    @RequestMapping (value = "/abc",method = RequestMethod.POST)
    public String hello2(String name,int age){
        return name+" hello Spring MVC"+age;
    }
    public class Person{
        String name;
        String id;
        int age;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }

        @Override
        public String toString() {
            return "person{" +
                    "name='" + name + '\'' +
                    ", id='" + id + '\'' +
                    ", age=" + age +
                    '}';
        }
    }
    @RequestMapping("hhh")
    //@RequestBody 规定需要传入参数
    public String  object(@RequestBody Person person){
        person.setName("lxc");
        person.setAge(1001);
        person.setAge(18);
        
        return person.toString();
    }
}